//
//  CurrentUserInfo.m
//  IMHX_Demo
//
//  Created by 郭健 on 16/3/31.
//  Copyright © 2016年 海城. All rights reserved.
//

#import "CurrentUserInfo.h"

@implementation CurrentUserInfo

    /** 所有属性的setter方法*/
-(void)setUserName:(NSString *)userName{
    //userDefault做缓存的时候，储存的值不能为nil
    if (userName ) {
        [[NSUserDefaults standardUserDefaults]setObject:userName forKey:@"name"];
    }
}

-(void)setPwd:(NSString *)pwd{
    if (pwd) {
        [[NSUserDefaults standardUserDefaults]setObject:pwd forKey:@"password"];
    }
}

-(void)setIsLogin:(BOOL)isLogin{
    [[NSUserDefaults standardUserDefaults]setBool:isLogin forKey:@"isLogin"];
}

    /**所有属性的getter方法*/
-(NSString *)userName{
    return [[NSUserDefaults standardUserDefaults]objectForKey:@"name"];
}

-(NSString *)pwd{
    return [[NSUserDefaults standardUserDefaults]objectForKey:@"password"];
}

-(BOOL)isLogin{
    return [[NSUserDefaults standardUserDefaults]boolForKey:@"isLogin"];
}

+(CurrentUserInfo *)sharedCurrentUserInfo{

    static CurrentUserInfo *currentUserInfo = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        currentUserInfo = [[CurrentUserInfo alloc]init];
    });
    return currentUserInfo;
}


@end
